package weaver.interfaces.jjy.duss.hr;

import com.sap.mw.jco.JCO;
import weaver.interfaces.jjy.duss.util.SAPConnPool;

import java.util.HashMap;
import java.util.Map;

/**
 * @Title: ecology-9-demo
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2020-05-09
 * @Description: 主管架构调整确认OA-SAP
 * @ModifyLog:
 **/

public class ZFM_HR_BZ_ZGJG_CONFIRM {
    public Map execute(Map<String,String> map) {

        SAPConnPool SAPConn = new SAPConnPool();
        JCO.Client myConnection = SAPConn.getConnection();
        JCO.Function bapi = SAPConn.excuteBapi("ZFM_HR_BZ_ZGJG_CONFIRM");
        JCO.ParameterList input = bapi.getImportParameterList();//输入参数和结构处理
        JCO.ParameterList inputtable = bapi.getTableParameterList();//输入表的处理
        //输入参数
        input.setValue("X","IV_COMMIT");//更新SAP
        input.setValue(map.get("IV_DATUM"),"IV_DATUM");//日期
        input.setValue(map.get("IV_NUMID"),"IV_NUMID");//OA主键
        //执行函数
        myConnection.execute(bapi);
        JCO.ParameterList out = bapi.getExportParameterList();//输出参数和结构处理
        JCO.ParameterList Table00 = bapi.getTableParameterList();//输出表的处理

        //返回处理结果以及日志
        JCO.Structure stu = out.getStructure("EV_OUTPUT");
        Map<String, String> mapreturn = new HashMap<>();
        String flag = (String) stu.getValue("ZFLAG");
        String message = (String) stu.getValue("ZMESG");
        mapreturn.put("flag", flag);
        mapreturn.put("message", message);
        System.out.println(mapreturn.toString());
        JCO.releaseClient(myConnection);
        return mapreturn;
    }

    public static void main(String[] args) {
        Map<String,String> map = new HashMap<>();
        ZFM_HR_BZ_ZGJG_CONFIRM bz_zgjg_confirm = new ZFM_HR_BZ_ZGJG_CONFIRM();
        map.put("IV_DATUM","20200602");
        map.put("IV_NUMID","1046513");
        bz_zgjg_confirm.execute(map);
    }
}
